package com.qf.day07;

/**
 * JavaBean 设计
 * 1.私有化属性 private 修饰属性
 * 2.对外提供get set 方法
 * 3.提供有参无参的构造
 */
public class User {
    private String name;
    private int age;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        if (name.length()<3 || name.length()>10){
            System.out.println("字符输入非法");
            this.name = "admin";
            return;
        }
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public User() {
    }

    public User(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public String toString() {
        return "User{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

}
